//
//  QuestionAnswer.m
//  SeaMelonSeeds_Counselor
//
//  Created by 尤振宇 on 2017/7/21.
//  Copyright © 2017年 杨笑. All rights reserved.
//

#import "QuestionAnswer.h"
#import "JHMacros.h"

@implementation QuestionAnswer

-(NSAttributedString *)content
{
    NSMutableAttributedString* attrString = [[NSMutableAttributedString alloc] initWithString:self.body];
    NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init];
    [style setLineSpacing:5];
    [attrString addAttribute:NSParagraphStyleAttributeName value:style range:NSMakeRange(0, self.body.length)];
    [attrString addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:16] range:NSMakeRange(0, self.body.length)];
    [attrString addAttribute:NSForegroundColorAttributeName value:k666666 range:NSMakeRange(0, self.body.length)];
    return attrString;
}

-(float)cell_W
{
    return SCREEN_WIDTH - 40/*cell 两边的间距*/;
}

-(void)setValue:(id)value forKey:(NSString *)key
{
    [super setValue:value forKey:key];
    if ([key isEqualToString:@"body"]) {
        self.text_H = [(NSString *)value heightForFontSize:16 andWidth:self.cell_W];
        self.text_H = (self.text_H / 19.5/*label的高*/ - 1) * 5 + self.text_H;
    }
}

@end


@implementation Comments

-(float)cell_W
{
    return SCREEN_WIDTH - 56;
}

-(void)setValue:(id)value forKey:(NSString *)key
{
    [super setValue:value forKey:key];
    if ([key isEqualToString:@"body"]) {
        self.text_H = [(NSString *)value heightForFontSize:15 andWidth:self.cell_W];
    }else if ([key isEqualToString:@"counselor"]){
        self.counselor = [[Counselor alloc]init];
        [self.counselor setValuesForKeysWithDictionary:value];
    }
}

@end
